

local function OpenMenu()
	//Base  menu
	menu = vgui.Create( "DFrame" )
	menu:SetSize(550,600)
	menu:Center()
	menu:SetTitle("Menu")
	menu:MakePopup()
	
	//VCommand tab
	vcomtab = vgui.Create( "DPanel", tmenu )
	vcomtab:SetSize( 500, 500 )
	vcomtab:Center()
	vcomtab.Paint = function()
		draw.DrawText("Voice commands:", "ScoreboardText", 30, 30, Color(255,255,255,255),TEXT_ALIGN_LEFT)
	end
	
	yes = vgui.Create( "DButton", vcomtab )
	yes:SetSize(105,35)
	yes:SetPos(vcomtab:GetWide()/4*2-105,vcomtab:GetTall()/5*2-35)
	yes:SetText("Yes")
	yes.DoClick = function()
		RunConsoleCommand("dm_vcom","vcom/yes.wav")
	end
	
	no = vgui.Create( "DButton", vcomtab )
	no:SetSize(105,35)
	no:SetPos(vcomtab:GetWide()/4*3-105,vcomtab:GetTall()/5*2-35)
	no:SetText("No")
	no.DoClick = function()
		RunConsoleCommand("dm_vcom","vcom/no.wav")
	end
	
	help = vgui.Create( "DButton", vcomtab )
	help:SetSize(105,35)
	help:SetPos(vcomtab:GetWide()/4*2-105,vcomtab:GetTall()/5*3-35)
	help:SetText("Help")
	help.DoClick = function()
		RunConsoleCommand("dm_vcom","vcom/help0"..math.random(1,2)..".wav")
	end
	
	cover = vgui.Create( "DButton", vcomtab )
	cover:SetSize(105,35)
	cover:SetPos(vcomtab:GetWide()/4*3-105,vcomtab:GetTall()/5*3-35)
	cover:SetText("Take cover")
	cover.DoClick = function()
		RunConsoleCommand("dm_vcom","vcom/cover.wav")
	end
	
	/*
	positive = vgui.Create( "DButton", vcomtab )
	positive:SetSize(105,35)
	positive:SetPos(vcomtab:GetWide()/4*2-105,vcomtab:GetTall()/5*4-35)
	positive:SetText("Positive")
	positive.DoClick = function()
		RunConsoleCommand("dm_vcom","vcom/positive0"..math.random(1,2)..".wav")
	end
	
	negative = vgui.Create( "DButton", vcomtab )
	negative:SetSize(105,35)
	negative:SetPos(vcomtab:GetWide()/4*3-105,vcomtab:GetTall()/5*4-35)
	negative:SetText("Negative")
	negative.DoClick = function()
		RunConsoleCommand("dm_vcom","vcom/negative0"..math.random(1,2)..".wav")
	end
	*/
	
	// XP tab
	xptab = vgui.Create( "DPanel", tmenu )
	xptab:SetSize( 500, 500 )
	xptab:Center()
	xptab.Paint = function()
		//draw.RoundedBox( 3, 0, 0, 500, 500, Color(120, 120, 120, 255) )
		//draw.RoundedBox( 0, 0, 0, 500, 20, Color(170, 170, 170, 255) )
		draw.DrawText("Your Stats:", "ScoreboardText", 30, 30, Color(255,255,255,255),TEXT_ALIGN_LEFT)
		draw.DrawText("XP:             "..LocalPlayer():GetNWInt("XP").."\n\nCurrent Class:  \""..LocalPlayer():GetNWString("class").."\"\n\nSoldier Level:  "..LocalPlayer():GetNWInt("soldierlvl").."     XP to next level:    "..math.abs(LocalPlayer():GetNWInt("soldierxp")-(LocalPlayer():GetNWInt("soldierlvl")*200)).."\n\nSupport Level:  "..LocalPlayer():GetNWInt("supportlvl").."     XP to next level:    "..math.abs(LocalPlayer():GetNWInt("supportxp")-(LocalPlayer():GetNWInt("supportlvl")*200)).."\n\nAssassin Level: "..LocalPlayer():GetNWInt("assassinlvl").."     XP to next level:    "..math.abs(LocalPlayer():GetNWInt("assassinxp")-(LocalPlayer():GetNWInt("assassinlvl")*200)).."\n\nMarksman Level: "..LocalPlayer():GetNWInt("marksmanlvl").."     XP to next level:    "..math.abs(LocalPlayer():GetNWInt("marksmanxp")-(LocalPlayer():GetNWInt("marksmanlvl")*200)), "DefaultFixed", 35, 55, Color(255,255,255,255),TEXT_ALIGN_LEFT)
	end
	
	//Help tab
	helptab = vgui.Create( "DPanel", tmenu )
	helptab:SetSize( 500, 500 )
	helptab:Center()
	helptab.Paint = function()
		//draw.RoundedBox( 3, 0, 0, 500, 500, Color(120, 120, 120, 255) )
		//draw.RoundedBox( 0, 0, 0, 500, 20, Color(170, 170, 170, 255) )
		draw.DrawText("List of chat commands:", "ScoreboardText", 30, 30, Color(255,255,255,255),TEXT_ALIGN_LEFT)
		cmdhelptext = {
		"\"!classmenu\" opens the class selection",
		"(this may cause your game to hang for a few seconds)",
		"",
		"\"!teammenu\" opens the team selection menu",
		"",
		"\"!resetstats\" resets your stats",
		"(WARNING: you will loose all unlocked weapons, perks will be reset)",
		"",
		"\"!loadout\" allows you to change what weapons you spawn with"
		}
		draw.DrawText(MultiLineText(cmdhelptext), "DefaultFixed", 35, 55, Color(255,255,255,255),TEXT_ALIGN_LEFT)
		
		draw.DrawText("Level info:", "ScoreboardText", 30, 155, Color(255,255,255,255),TEXT_ALIGN_LEFT)
		ranklvlhelptext = {
		"Your level determines what weapons you spawn with,",
		"and how effective your perks are.",
		"",
		"Level up by gaining experience points (XP)",
		"You get XP by killing enemies, and helping teammates,",
		"by supplying them with ammo and health."
		}
		draw.DrawText(MultiLineText(ranklvlhelptext), "DefaultFixed", 35, 180, Color(255,255,255,255),TEXT_ALIGN_LEFT)
		
		draw.DrawText("Perks:", "ScoreboardText", 30, 250, Color(255,255,255,255),TEXT_ALIGN_LEFT)
		perkhelptext = {
		"Perks are special abilites that vary depending on your rank and class.",
		"",
		"Soldier: Body armor and hit tracer (always active)",
		"",
		"Support: Construction tool. Allows you to build strategic objects:",
		"BARRIER: A small concrete wall that provides cover. Left-click to build",
		"while having the building tool equipped.",
		"Barriers become more durable as your level increases.",
		"You can build more barriers at higher levels.",
		"DISPENSER: A small machine that provides your team with health",
		"and ammo. Dispensers give out more health and ammo at higher levels.",
		"They are very vulnerable, and take little punishment before breaking.",
		"",
		"Assassin: Cloak. Makes you hard to see for a short period of time.",
		"The cloak hides you better, and lasts longer at higher levels.",
		"",
		"Marksman: Radar. Highlights other players, so you can see them",
		"through walls. Lasts longer at higher levels."
		}
		draw.DrawText(MultiLineText(perkhelptext), "DefaultFixed", 35, 275, Color(255,255,255,255),TEXT_ALIGN_LEFT)
	end
	
	
	//tabs
	tmenu = vgui.Create( "DPropertySheet", menu )
	tmenu:SetSize( 525, 525 )
	tmenu:Center()
	tmenu:AddSheet( "Voice com", vcomtab, "gui/silkicons/wrench", false, false, "In-Game voice commands" )
	tmenu:AddSheet( "Stats", xptab, "gui/silkicons/user", false, false, "Veiw your XP and other stats" )
	tmenu:AddSheet( "Help" , helptab, "gui/silkicons/picture_edit", false, false, "Commands, levels and perks" )
end

function MultiLineText(lines)
	local text = lines[1]
	for k,v in pairs(lines) do
		if k > 1 then text = text.."\n"..v end
	end
	return text
end

hook.Add( "OnSpawnMenuOpen", "DisallowSpawnMenu", OpenMenu)

local function CloseMenu()
	if pcall( function() menu:SetVisible( false ) end ) then
		menu:SetVisible( false )
	end
end
 
hook.Add( "OnSpawnMenuClose", "DisallowSpawnMenu", CloseMenu)


local function DisallowSpawnMenu( )
	return false
end
 
hook.Add( "SpawnMenuOpen", "DisallowSpawnMenu", DisallowSpawnMenu)